#!/bin/bash
#当前日期
today=`date "+%Y-%m-%d"`

EXCLUDEDIRS="/proc"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/sys"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/mnt"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/var/*"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/usr/share/{foomatic,backgrounds,perl5,fonts,cups,qt4,groff,kde4,icons,pixmaps,emacs,gnome-background-properties,sounds,gnome,games,desktop-directories}"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/var/*"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/data/*"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/opt/{code,goLibs,nodejs}"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/opt/{code,goLibs,nodejs}"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/root/{.vpython-root,tools,OpenMind,.cache,tools}"
EXCLUDEDIRS+=" "
EXCLUDEDIRS+="/tmp/*"
EXCLUDEDIRS+=" "

OPTIONS+="--numeric-owner"
OPTIONS+=" "
OPTIONS+="--exclude-backups"
OPTIONS+=" "
OPTIONS+="--exclude-caches-all"
OPTIONS+=" "



EXCLUDEFILES=`find /root/LIZHI/ -name core.[0-9]* -o -name *.log`


for ditem in $EXCLUDEDIRS ; do
	OPTIONS+=" --exclude=$ditem "
done


for fitem in $EXCLUDEFILES ; do
	OPTIONS+=" --exclude=$fitem "
done

echo "OPTIONS is $OPTIONS"
tar $OPTIONS -zcvf /mnt/CentOS7-BaseImage-$today.tar /root/LIZHI/rtc_media_sg/ /root/.bashrc  /root/tools/node-v14.18.1-linux-x64/ /tmp /bin  /boot  /data  /dev  /etc  /lib  /lib64  /media  /mnt  /opt/ThirdParty/  /proc  /run  /sbin  /srv  /sys    /usr  /var